<template>
  Counter {{ JSON.stringify(data) }} {{ data?.code }}
  <a-button type="primary" @click="handleClick">antd</a-button>
</template>

<script setup lang="ts">
// 设置访问路径
definePageMeta({ path: 'count.html' })
const data = ref<{ code: number, msg: string, data: null }>()
// nextTick(async () => {
//   if (import.meta.client) {
//     const res = await useFetch('/api/hello', { method: 'GET' })
//     data.value = res.data.value as { code: number, msg: string, data: null }
//   }
// })
// 服务器端请求数据
const res = await useFetch('/api/hello', { method: 'GET' })
data.value = res.data.value as { code: number, msg: string, data: null }

const handleClick = () => {
  console.log(data.value)
}
</script>